/* Cell Based Lighting */

#include "LightUtils.hlsl"

// Thread Count
#define NUM_THREADS_X	16
#define NUM_THREADS_Y	16
#define NUM_THREADS_Z	1
#define MAX_PASSES		8

// Compute Input
struct ComputeInput
{
	uint3	GroupID				: SV_GroupID;
	uint	GroupIndex			: SV_GroupIndex;
	uint3	GroupThreadID		: SV_GroupThreadID;
	uint	GroupThreadIndex	: SV_DispatchThreadID;
};

// Textures
Texture2D<float4> g_RenderOutput			: register(t0);
Texture2D<float4> g_Direct2DTarget			: register(t1);

RWTexture2D<float4> g_OutputTexture			: register(u0);

[numthreads(NUM_THREADS_X, NUM_THREADS_Y, NUM_THREADS_Z)]
void main(ComputeInput input)
{
	// Compute to Which pixel we correspond
	uint2 PixelIndex = uint2(0, 0);
	PixelIndex.x = (input.GroupID.x * NUM_THREADS_X) + input.GroupThreadID.x;
	PixelIndex.y = (input.GroupID.y * NUM_THREADS_Y) + input.GroupThreadID.y;

	// Sample the Pixels
	float4 d3dClr = g_RenderOutput[PixelIndex];
	float4 d2dClr = g_Direct2DTarget[PixelIndex];
	
	// Calculate the Final Color
	float4 finalClr = d3dClr + d2dClr;
	
	// Output the Color to the Texture
	g_OutputTexture[PixelIndex] = finalClr;
}